function showWalletCrombs(){
	crombs = getCrombs();
	var cards = new Array(crombs.length);
	cards.index=0;
	$(document).ready(function(){
		for (var i = 0;i<crombs.length;i++){
		  cards[i] = new Card(new CrombRenderer(crombs[i]));
		}
		if ($("#wallet").length > 0){
		   $("#wallet").remove();
		}
		var wallet = new Wallet("wallet",cards,"Crombs");
		wallet.init();
		console.log("INIT Run!");
	});
}

function CrombRenderer(cromb){
  this.cromb = cromb;
  function render(){
     cromb = this.cromb;
     return "<div class='cromb'>"+cromb.message+"<div class='signature'>"+cromb.author+"</div><div class='datetime'>"+cromb.datetime+"</div></div>";
  }
  this.render = render;
}

function Card(renderer){
  this.renderer = renderer;
  function display(){
     $("#wallet").append("<div id='card' class='card'>"+renderer.render()+"</div>");
  }
  this.display = display;
  
}

function Wallet(id,cards,title){
  this.cards = cards;
  this.cards.index = 0;
  this.title = title;
  function init(){
     $("#mainview").append("<div id='wallet'><div class='wallettitle'>"+title+"</div></div>");
	 card = cards[cards.index];
	 card.display();
	 
  }
  this.init = init;
  function next(){
    console.log("Move next...");
 	if (cards.index < cards.length-1){
	  cards.index++;
	}	
	$("#card").remove();
	card = cards[cards.index];
	card.display();
	if (cards.index >= cards.length-1){
	  $("#walletnext").remove();
	}
    
  }
  function previous(){
    console.log("Move previous...");
    if (cards.index > 0){
	  cards.index--;
	}
	if($("#walletprevious").length> 0 && cards.index===0){
	  $("#walletprevious").remove();
	}
	$("#card").remove();
	card = cards[cards.index];
	card.display();
	if($("#walletnext").length=== 0 && cards.length>0){
	  displayNext();
	}
  }
  this.next = next;
  this.previous = previous;

	$(document).ready(function(){
		$("#mainview").on("swipeleft",function(){
			next()
		});
		$("#mainview").on("swiperight",function(){
			previous()
		});
	});
}
